package com.smart.list.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.smart.list.analizer.TextAnalyzer;
import com.smart.list.analizer.impl.TextAnalyzerLuceneImpl;
import com.smart.list.dao.TaskDao;
import com.smart.list.entity.Task;
import com.smart.list.service.TaskService;

@Repository("TaskService")
public class TaskServiceImpl implements TaskService {
	private static final Logger logger = LoggerFactory.getLogger(TaskServiceImpl.class);
	
	@Autowired
	public TaskServiceImpl(TaskDao taskDao) {
		super();
		this.taskDao = taskDao;
	}	
	
	public TaskServiceImpl() {
		super();
	}

	private TaskDao taskDao;
	private List<String> context;

	public Task createTask(String taskArg) {
		Task task = new Task(taskArg);
		task.setCategories(getCategories(taskArg));
		task.setImportance(Task.Importance.NORMAL);
		task.setStatus(false);
		task.setCreated(new Date());
		return task;
	}

	private List<String> getCategories(String taskArg){
		TextAnalyzer taskAnalizer = new TextAnalyzerLuceneImpl();
		List<String> context = new ArrayList<String>();
		Long id = (long) 0;
		List<String> categories = taskAnalizer.getCategories(taskArg, id , context);
		return categories;
		
	}

	

	@Override
	public List<Task> getTasks(String context) {
		List<Task> tasks = new ArrayList<Task>();
		return tasks;
	}



}
